﻿using System.Collections.Generic;
using Microsoft.Practices.Unity;
using StockholmsStad.Windows.UI.Infrastructure.Interfaces;
using StockholmsStad.Windows.UI.Modules.Couple.Interfaces;
using StockholmsStad.Windows.UI.Modules.Couple.Models;
using StockholmsStad.Windows.UI.Facade;
using StockholmsStad.Runtime.Serialization.DataContract;
using StockholmsStad.Runtime.Serialization.DataContract.Enums;

namespace StockholmsStad.Windows.UI.Modules.Couple.Services
{
    public class LawTextService : ILawTextService
    {
        private List<InformationText> lawTexts;
        private IApplicationService applicationService;

        [Dependency]
        public IApplicationService ApplicationService
        {
            set { applicationService = value; }
        }

        public LawTextsPresentationModel GetLawTexts(InformationTextType type)
        {
            var model = new LawTextsPresentationModel();

            var user = applicationService.GetCurrentUser();

            if (lawTexts == null || lawTexts.Count == 0)
                lawTexts = new MaintenanceFacade(user).GetTexts((int) type);

            model.LawTexts = lawTexts;
            return model;
        }
    }
}



